//
//  BVideoDownloader.h
//  Bullet
//
//  Created by  on 2019/9/18.
//  Copyright © 2019 . All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN


typedef NS_ENUM(NSInteger,BFileDownloaderStatus) {
    BFileDownloaderStatusDownlodding,
    BFileDownloaderStatusError,
    BFileDownloaderStatusFinished
};

@class BFileDownloaderTool;
@protocol BFileDownloaderToolDelegate <NSObject>

//@optional
/**
 大文件下载完成代理方法
 
 @param fileDownLoader 下载器
 @param filePath 返回文件路径，如果isCacheLocal为Yes，说明下载成功，返回本地路径，否则下载失败或未下载完成，返回原路径
 @param isCacheLocal 是否已将大文件缓存到本地
 */
- (void)fileDownloader:(BFileDownloaderTool *)fileDownLoader didFinishedWithFilePath:(NSString *)filePath isCacheLocal:(BOOL)isCacheLocal;

@end

@interface BFileDownloaderTool : NSObject

@property (nonatomic,weak) id<BFileDownloaderToolDelegate> cDelegate;//
@property (nonatomic,strong) NSObject<BFileDownloaderToolDelegate> *parentObj;// 
@property (atomic,assign) NSInteger type;//
@property (nonatomic,copy,readonly) NSString *urlStr;
@property (nonatomic,assign,readonly) BFileDownloaderStatus status;//

- (instancetype)initWithUrl:(NSString *)urlStr baseUrl:(NSString *)baseUrl type:(NSInteger)type target:(id<BFileDownloaderToolDelegate>)target queue:(NSOperationQueue *)queue;
- (instancetype)initWithUrl:(NSString *)urlStr baseUrl:(NSString *)baseUrl type:(NSInteger)type target:(id<BFileDownloaderToolDelegate>)target queue:(NSOperationQueue *)queue preload:(BOOL)preload;
- (void)startDownload;

/**
 停止下载，并清理缓存
 */
- (void)stopAndClean;

@end

NS_ASSUME_NONNULL_END
